package com.szml.controller;

import com.szml.dto.LoginFormDTO;
import com.szml.entity.User;
import com.szml.result.Result;
import com.szml.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/user")
public class UserController {
    /**
     * 登录功能的映射路径
     **/
    @Resource
    private UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody LoginFormDTO loginForm, HttpSession session) {
        // TODO 实现登录功能
        return userService.login(loginForm, session);
    }

    @PostMapping("/register")
    public Result register(@RequestBody User user, HttpSession session) {
        return userService.register(user, session);
    }

}
